#include "lolevel.h"
#include "platform.h"
#include "core.h"

static long *nrflag = (long*)0x6B6C;

#include "../../../generic/capt_seq.c"

void __attribute__((naked,noinline)) sub_FF94EDAC_my(long p)
{
    asm volatile (
                "STMFD   SP!, {R4,R5,LR}\n"
                "LDR     R3, =0x7D08C\n"
                "LDR     R5, =0x6B68\n"
                "SUB     SP, SP, #4\n"
                "LDR     R1, =0xFFFFFFFF\n"
                "STR     R0, [R5]\n"
                "LDR     R0, [R3]\n"
                "BL      sub_FF820EBC\n" // ClearEventFlag
                "BL      sub_FF9547A4\n"
                "LDR     R0, [R0,#0x7C]\n"
                "BL      sub_FF8A085C\n" // IsEmptyWriteCache_44
                "BL      sub_FF94ED20\n"
                "BL      capt_seq_hook_set_nr\n"	//+
                "LDR     R3, =0x6B70\n"
                "LDR     R0, [R3]\n"

                "B       sub_FF94EDE4\n" // ---> jump to end of function in ROM
    );
}


void __attribute__((naked,noinline)) sub_FF94BE74_my(long p)
{
    asm volatile (
       "STMFD   SP!, {R4,R5,LR}\n"
       "LDR     R5, [R0,#0xC]\n"
       "BL      sub_FF954548\n"
       "CMP     R0, #0\n"
       "BNE     loc_FF94BE8C\n"
       "BL      sub_FF954554\n"
  "loc_FF94BE8C:\n"
       "MOV     R0, R5\n"
       "BL      sub_FF94DC14\n"
       "TST     R0, #1\n"
       "MOV     R2, R5\n"
       "MOV     R1, #1\n"
       "BEQ     loc_FF94BEAC\n"
       "LDMFD   SP!, {R4,R5,LR}\n"
       "B       sub_FF94A48C\n"
  "loc_FF94BEAC:\n"
       "BL      sub_FF9879BC\n"
       "BL      sub_FF9498EC\n"
       "MOV     R4, R0\n"
       "BL      sub_FF825DAC\n"
       "ADD     R3, R5, R5,LSL#1\n"
       "ADD     R4, R4, R3,LSL#5\n"
       "STR     R0, [R4,#4]\n"
       "MOV     R0, R5\n"
       "BL      sub_FF94F5C0\n"
       "BL      sub_FF94E188\n"
       "BL      sub_FF94E128\n"
       "MOV     R0, R5\n"
       "BL      sub_FF94EDAC_my\n"				//x
       "BL      capt_seq_hook_raw_here\n"			//+
       "MOV     R2, R5\n"
       "MOV     R1, #1\n"
       "BL      sub_FF94A48C\n"
       "LDMFD   SP!, {R4,R5,LR}\n"
       "B       sub_FF94EFA8\n"
    );
}

void __attribute__((naked,noinline)) capt_seq_task()
{

    asm volatile (
       "STMFD   SP!, {R4,LR}\n"
       "SUB     SP, SP, #4\n"
       "MOV     R4, SP\n"
       "B       loc_FF94C200\n"
  "loc_FF94C0B8:\n"
       "LDR     R2, [SP]\n"
       "LDR     R3, [R2]\n"
       "MOV     R0, R2\n"
       "CMP     R3, #0x14\n"
       "LDRLS   PC, [PC,R3,LSL#2]\n"
       "B       loc_FF94C1D4\n"
       ".long loc_FF94C124\n"
       ".long loc_FF94C130\n"
       ".long loc_FF94C138\n"
       ".long loc_FF94C148\n"
       ".long loc_FF94C140\n"
       ".long loc_FF94C150\n"
       ".long loc_FF94C158\n"
       ".long loc_FF94C164\n"
       ".long loc_FF94C16C\n"
       ".long loc_FF94C178\n"
       ".long loc_FF94C180\n"
       ".long loc_FF94C188\n"
       ".long loc_FF94C190\n"
       ".long loc_FF94C198\n"
       ".long loc_FF94C1A0\n"
       ".long loc_FF94C1AC\n"
       ".long loc_FF94C1B4\n"
       ".long loc_FF94C1BC\n"
       ".long loc_FF94C1C4\n"
       ".long loc_FF94C1CC\n"
       ".long loc_FF94C1E8\n"
  "loc_FF94C124:\n"
       "BL      sub_FF94D870\n"
       "BL      shooting_expo_param_override\n"		//+
       "BL      sub_FF949FF4\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C130:\n"
       "BL      sub_FF94BE74_my\n"				//x
       "B       loc_FF94C1E4\n"
  "loc_FF94C138:\n"
       "BL      sub_FF94DC04\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C140:\n"
       "BL      sub_FF94CB24\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C148:\n"
       "BL      sub_FF94CB80\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C150:\n"
       "BL      sub_FF94CD74\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C158:\n"
       "BL      sub_FF94D964\n"
       "BL      sub_FF949FF4\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C164:\n"
       "BL      sub_FF94BF28\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C16C:\n"
       "BL      sub_FF94D9CC\n"
       "BL      sub_FF949FF4\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C178:\n"
       "BL      sub_FF94CB80\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C180:\n"
       "BL      sub_FF94E2C4\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C188:\n"
       "BL      sub_FF94E54C\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C190:\n"
       "BL      sub_FF94E5B4\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C198:\n"
       "BL      sub_FF94E66C\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C1A0:\n"
       "MOV     R0, #0\n"
       "BL      sub_FF94E704\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C1AC:\n"
       "BL      sub_FF94E854\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C1B4:\n"
       "BL      sub_FF94E8BC\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C1BC:\n"
       "BL      sub_FF94E968\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C1C4:\n"
       "BL      sub_FF94EA2C\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C1CC:\n"
       "BL      sub_FF94EA58\n"
       "B       loc_FF94C1E4\n"
  "loc_FF94C1D4:\n"
       "MOV     R1, #0x2DC\n"
       "LDR     R0, =0xFF94BC20\n"
       "ADD     R1, R1, #2\n"
       "BL      sub_FF813BDC\n"
  "loc_FF94C1E4:\n"
       "LDR     R2, [SP]\n"
  "\n"
  "loc_FF94C1E8:\n"
       "LDR     R3, =0x7D014 \n"
       "LDR     R1, [R2,#4]\n"
       "LDR     R0, [R3]\n"
       "BL      sub_FF820D20\n"
       "LDR     R0, [SP]\n"
       "BL      sub_FF94BC9C\n"
  "loc_FF94C200:\n"
       "LDR     R3, =0x7D018\n"
       "MOV     R1, R4\n"
       "LDR     R0, [R3]\n"
       "MOV     R2, #0\n"
       "BL      sub_FF8214DC\n"
       "TST     R0, #1\n"
       "BEQ     loc_FF94C0B8\n"
       "MOV     R1, #0x24C\n"
       "LDR     R0, =0xFF94BC20\n"
       "ADD     R1, R1, #3\n"
       "BL      sub_FF813BDC\n"
       "BL      sub_FF822C6C\n"
       "ADD     SP, SP, #4\n"
       "LDMFD   SP!, {R4,PC}\n"
 );
}

